package com.etc.dto;

/**
 * 控制器返回对象
 */
public class Result<T> {

    private T data;         // 返回结果
    private int status;      // 返回状态 0 1
    private String message; // 返回说明

    /**
     * 查到结果
     * @param data
     * @return
     */
    public Result<T> ok(T data) {
        setData(data).setMessage("success").setStatus(1);
        return this;
    }

    /**
     * 查无结果
     * @param state
     * @param message
     * @return
     */
    public Result<T> fail(int status, String message) {
        setMessage(message).setStatus(status);
        return this;
    }

    public T getData() {
        return data;
    }

    public Result<T> setData(T data) {
        this.data = data;
        return this;
    }

    public int getStatus() {
        return status;
    }

    public Result<T> setStatus(int status) {
        this.status = status;
        return this;
    }

    public String getMessage() {
        return message;
    }

    public Result<T> setMessage(String message) {
        this.message = message;
        return this;
    }


}
